﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NetPE.Core.Pe;

namespace NetPE.TreeNodes
{
    public class DirectoriesNode : BaseNode
    {
        public DirectoriesNode(OptionalHeader.DataDirectoriesHeader hdr)
            : base(hdr)
        {
            this.hdr = hdr;
            this.Text = "Data Directories";
            this.ImageIndex = this.SelectedImageIndex = NodeType.Header;

            foreach (DataDirectoryEntry i in hdr)
            {
                this.Nodes.Add(new DirectoryNode(i));
            }
        }

        OptionalHeader.DataDirectoriesHeader hdr;
        public override object Data { get { return hdr; } }

        public override BaseEditor GetEditorControl()
        {
            return new BaseEditor();
        }
    }

    public class DirectoryNode : BaseNode
    {
        public DirectoryNode(DataDirectoryEntry hdr)
            : base(hdr)
        {
            this.hdr = hdr;
            this.Text = hdr.Type.ToString();
            this.ImageIndex = this.SelectedImageIndex = NodeType.Header;
        }

        DataDirectoryEntry hdr;
        public override object Data { get { return hdr; } }

        public override BaseEditor GetEditorControl()
        {
            return new DirectoryLocationEditor(this);
        }
    }
}
